/*
 * DEC.c
 *
 *  Created on: Jan 20, 2014
 *      Author: adijoshi
 */
//INCLUDES
#include "includes.h"


/*
 * Function: func_DEC
 *
 * Inputs:	 Mnemonic, Address_of_destination
 * Outputs:  (None)
 * Condition  Codes:
 * 		Z:  set  if  result  =  0;  cleared  otherwise
 * 		N:  set  if  result  <  0;  cleared  otherwise
 * 		C:  set  if  destination held 100000;  cleared otherwise
 * 		V:  not affected
 */

void func_DEC(int mnemonic, unsigned short address_destination)
{
	unsigned short data,result;
	int result_32_bit;

	data 			= read_from_memory(address_destination,DATA);
	result_32_bit 	= data + get_twos_complement(1);
	result	= (unsigned short) result_32_bit;

	write_in_memory(address_destination,result,DATA);

	update_N_flag(DEC,result);
	update_Z_flag(result);
	// overflow flag not affected
	update_C_flag(DEC,data,0,result,0);
}




